<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作用域插槽</title>
</head>
<body>
    <div id="app">
        <father></father>
    </div>
    <!--  -->
    <script src="vue.js"></script>
    <script>

        Vue.component('father',{
            template:`
            <div>
                <!-- 2.接收值 -->            
                <child v-slot="slotProps">
                    {{slotProps}}
                    <ul>
                        <li v-for="item in slotProps.students" :key="item">{{item}}</li>
                    </ul>
                </child>
                <hr>
                <child v-slot="slotProps">
                    {{slotProps}}
                    <ol>                        
                        <li v-for="item in slotProps.students" :key="item">{{item}}</li>
                    </ol>
                </child>
            </div>
            `,
        });

        Vue.component('child',{
            data(){
                return {
                    students:['lisi','limong','lisan'],
                }
            },
            template:`
            <div>
                <h3>学生 列表</h3>
                <!-- 1.传值-子组件的数据 -->
                <slot :students="students"></slot>
            </div>
            `,
        });

        new Vue({
            el:"#app",
            data(){
                return {
                }
            },
        })
    
    </script>
    
</body>
</html>